This page last changed on Apr 09, 2007 by cholmes.

Work has been done by several people to get Google Maps type styling in SLD. This page will be a shared resource on how people have done it, and hopefully will turn in to a full blown tutorial on how to make your own google maps with GeoServer.

There are currently three different attempts. Tutorial 1 is just a sample SLD that you can download and see how it was done. Tutorial 2 walks through more specifics of how to do it. And Geoserver and Google SLDs is an end user tutorial on setting up http://sigma.openplans.org styles.

Tutorial 1

You can download GĂ©rald's SLD files: basemap_sld.zip

Tutorial 2


 
Versions of Software used:
PostgreSQL: 8.1 (pgAdmin III version 1.4.2)
PostGIS: 1.1.5
GeoServer: 1.3.4

Introduction

This tutorial was written from a Windows perspective for the geographical region of one county. The primary focus of the tutorial, at this time, is to display road centerline data in a manner consistent with the look and feel of a Google map.  At a later date, some of the finer details will be added to the tutorial to complete the overall appearance of a Google-style map.

The tutorial assumes that you have already installed PostgreSQL, PostGIS and Geoserver.  The PostgreSQL database name chosen for this example is called "postgis" with a "postgres" user and "postgres" as the password. The tutorial also assumes that you have the following shapefile data available.

1.   "roads.shp" (line) with the following fields:
           roadclass (attributes should be: INTERSTATE, HIGHWAY, or OTHER)
           label (the full street name)
2.   "countyboundary.shp" (polygon) with the following fields
           (No fields are required at this time)
3.   "corporatelimits.shp" (polygon with the following fields
           (No fields are required at this time)
4.   "water.shp" (polygon) with the following fields
           (No fields are required at this time)

For simplicity, put all of the shapefiles in one folder.  This tutorial also assumes all your shapefile data is in WGS84 (SRS=4326). If your shapefile data is in Geographic NAD83 (which is a more common geographic coordinate system within the GIS community), don't worry, that's close enough for this demonstration.

You will need a MapBuilder site to review your data at the end of the tutoral.  Additionally SLD files are required to complete this tutorial. Both can be found here.

Step 1 - Load shapefiles into the PostGIS database

1. Open a Command Window
2. Change your directory to your shapefile folder directory
3. Type: shp2pgsql -s 4326 -i -I roads roads > roads.sql
4. Type: shp2pgsql -s 4326 -i -I water water > water.sql
5. Type: shp2pgsql -s 4326 -i -I corporatelimits corporatelimits > corporatelimits.sql
6. Type: shp2pgsql -s 4326 -i -I countyboundary countyboundary > countyboundary.sql

(Note:The shp2pgsql commands above will write sql files into the same directory as your shapefiles.)

7. Open up PgAdmin III and select the "postgis" database
8. Go to Tools, Query Tool
9. Go to File, Open, and Browse to the folder containing the SQL files created above.
10. Select one of the SQL files and hit "Open"
11. Go to Query, Execute
12. Go to step 9 and repeat for each of the SQL files created above.

Step 2 - Set up the Datastore, Styles, and FeatureTypes in GeoServer

1. Make sure GeoServer has been started
2. Open the GeoServer Administration page
3. Click on Config
4. Enter the username and password. (admin/geoserver initially)
5. Click on Config, Stores, New
6. Drop down and select Postgis and key in POSTGISDB as theDataStore ID.
7. Click on the "New" button.
8. Drop down and select the "cite" namespace (this is just the one that I used, you could create our own). Enter the database name "postgis" and the postgres user and password.
9. Click on the "Submit" button.
10. Click on Apply, and Save on the left.
11. Click on Config, Data, Style, New
12. Create the following Styles

            StyleID: googlesque_roads
            SLD: googlesque_roads.sld

            StyleID: googlesque_corporatelimits
            SLD: googlesque_corporatelimits.sld

            StyleID: googlesque_water
            SLD: googlesque_water.sld

            StyleID: googlesque_countyboundaries
            SLD: googlesque_countyboundaries.sld

13. Click Apply and Save on the left.
14. Click on Config, Data, FeatureType
15. Click New
16. Drop down and select POSTGIS::::roads and click New
17. Drop down the Style and select googlesque_roads.
18. Enter 4326 as the SRS (spatial reference system)
19. Click on the "Generate" button to create the bounding box.
20. Click on the "Submit" button
21. Do steps 12 through 17 for each layer making sure to match each layer to its appropriate StyleID. The FeatureType name should match the postgis database table names.
22. Once you're done setting up each FeatureType click Apply and Save on the left.

Setting up the Map Builder site

      1. Copy the samplesite folder to: C:\<your geoserver 1.3.4 directory>\server\geoserver\data\mbdemos\demo\ directory

Opening the Map Builder Sample Site

      1. Point your browser to: http://127.0.0.1:8080/geoserver/data/mbdemos/demo/samplesite/index.html


mapalagoogle.jpg (image/jpeg)
basemap_sld.zip (application/zip)
tutorialfiles.zip (application/x-zip-compressed)
sample.JPG (image/jpeg)

is basemap_sld.zip suppose to contain the .shp (roads.shp, countyboundary.shp, corporatelimits.shp, water.shp ) file for the tutorial? I only see basemap_xxx.sld and no shapsfiles.

Posted by timding at Nov 27, 2006 05:38

Basemap_sld.zip only contains the sld files.  The idea was that roads.shp, countyboundary.shp, corporatelimits.shp, and water.shp would be your own shapefiles.  I could have provided the shapefiles as well but they probably wouldn't interest anyone since they are for only one county in rural North Dakota.

Posted by [email protected] at Dec 07, 2006 11:06

Ooops.. I misspoke.  Here's the deal.  There are two tutorials on this page.  You're question is actually a cross between the two tutorials and that won't work.  Basemap_sld.zip has nothing to do with the shapefiles I spoke about and the reason why there is a second tutorial is because I, personally, found the first one to be quite insufficient.

Posted by [email protected] at Dec 07, 2006 11:10
Document generated by Confluence on Jan 16, 2008 23:27